﻿Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.CompilerServices
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Drawing
Imports System.IO
Imports System.Runtime.CompilerServices
Imports System.Windows.Forms

Namespace Stickam_Client
    <DesignerGenerated> _
    Public Class Form_ExecuteStatement
        Inherits Form
        ' Methods
        Public Sub New()
            Me.InitializeComponent
        End Sub

        Private Sub Clear_Click(ByVal sender As Object, ByVal e As EventArgs)
            Me.ScriptCode.Clear
        End Sub

        <DebuggerNonUserCode> _
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            Try 
                If (disposing AndAlso (Not Me.components Is Nothing)) Then
                    Me.components.Dispose
                End If
            Finally
                MyBase.Dispose(disposing)
            End Try
        End Sub

        Private Sub Execute_Click(ByVal sender As Object, ByVal e As EventArgs)
            If Me.CheckBox1.Checked Then
                Me.FormParent.ExecuteServerScript(Me.ScriptCode.Text)
            Else
                Me.FormParent.ExecuteScript(Me.ScriptCode.Text)
            End If
        End Sub

        Private Sub FileList_SelectedValueChanged(ByVal sender As Object, ByVal e As EventArgs)
            If Me.CanLoad Then
                Me.FilePath.Text = Conversions.ToString(Operators.AddObject((Me.FormParent.MyVars.currentDirectory & "Scripts\"), Me.FileList.SelectedValue))
                Me.ScriptCode.Text = Globals.LoadFile(Me.FilePath.Text)
            End If
            If Not Me.CanLoad Then
                Me.CanLoad = True
            End If
        End Sub

        <DebuggerStepThrough> _
        Private Sub InitializeComponent()
            Dim manager As New ComponentResourceManager(GetType(Form_ExecuteStatement))
            Me.ScriptCode = New TextBox
            Me.Execute = New Button
            Me.Clear = New Button
            Me.OpenLoader = New Button
            Me.FileList = New ComboBox
            Me.RefreshList = New Button
            Me.FilePath = New TextBox
            Me.LoadFromFile = New Button
            Me.CheckBox1 = New CheckBox
            Me.SuspendLayout
            Me.ScriptCode.AcceptsTab = True
            Me.ScriptCode.Font = New Font("Courier New", 9!, FontStyle.Regular, GraphicsUnit.Point, 0)
            Dim point As New Point(1, 1)
            Me.ScriptCode.Location = point
            Me.ScriptCode.Multiline = True
            Me.ScriptCode.Name = "ScriptCode"
            Me.ScriptCode.ScrollBars = ScrollBars.Vertical
            Dim size As New Size(&H165, &HCF)
            Me.ScriptCode.Size = size
            Me.ScriptCode.TabIndex = 0
            Me.ScriptCode.WordWrap = False
            Me.Execute.FlatStyle = FlatStyle.Popup
            Me.Execute.Font = New Font("Microsoft Sans Serif", 6.75!, FontStyle.Regular, GraphicsUnit.Point, 0)
            point = New Point(1, &HD1)
            Me.Execute.Location = point
            Me.Execute.Name = "Execute"
            size = New Size(&HEF, &H12)
            Me.Execute.Size = size
            Me.Execute.TabIndex = 1
            Me.Execute.Text = "EXECUTE"
            Me.Execute.UseCompatibleTextRendering = True
            Me.Execute.UseVisualStyleBackColor = True
            Me.Clear.FlatStyle = FlatStyle.Popup
            Me.Clear.Font = New Font("Microsoft Sans Serif", 6.75!, FontStyle.Regular, GraphicsUnit.Point, 0)
            point = New Point(&H101, &HD1)
            Me.Clear.Location = point
            Me.Clear.Name = "Clear"
            size = New Size(50, &H12)
            Me.Clear.Size = size
            Me.Clear.TabIndex = 2
            Me.Clear.Text = "CLEAR"
            Me.Clear.UseCompatibleTextRendering = True
            Me.Clear.UseVisualStyleBackColor = True
            Me.OpenLoader.FlatStyle = FlatStyle.Popup
            Me.OpenLoader.Font = New Font("Microsoft Sans Serif", 6.75!, FontStyle.Regular, GraphicsUnit.Point, 0)
            point = New Point(&H134, &HD1)
            Me.OpenLoader.Location = point
            Me.OpenLoader.Name = "OpenLoader"
            size = New Size(50, &H12)
            Me.OpenLoader.Size = size
            Me.OpenLoader.TabIndex = 6
            Me.OpenLoader.Text = "OPEN  >"
            Me.OpenLoader.UseCompatibleTextRendering = True
            Me.OpenLoader.UseVisualStyleBackColor = True
            Me.FileList.DropDownStyle = ComboBoxStyle.Simple
            Me.FileList.DropDownWidth = &H90
            Me.FileList.FormattingEnabled = True
            Me.FileList.IntegralHeight = False
            point = New Point(&H167, 1)
            Me.FileList.Location = point
            Me.FileList.Name = "FileList"
            size = New Size(&H90, &HBA)
            Me.FileList.Size = size
            Me.FileList.TabIndex = 7
            Me.RefreshList.FlatStyle = FlatStyle.Popup
            Me.RefreshList.Font = New Font("Microsoft Sans Serif", 6.75!, FontStyle.Regular, GraphicsUnit.Point, 0)
            point = New Point(&H167, &HBC)
            Me.RefreshList.Location = point
            Me.RefreshList.Name = "RefreshList"
            size = New Size(140, &H12)
            Me.RefreshList.Size = size
            Me.RefreshList.TabIndex = 8
            Me.RefreshList.Text = "REFRESH"
            Me.RefreshList.UseCompatibleTextRendering = True
            Me.RefreshList.UseVisualStyleBackColor = True
            point = New Point(&H167, &HCF)
            Me.FilePath.Location = point
            Me.FilePath.Name = "FilePath"
            size = New Size(&H63, 20)
            Me.FilePath.Size = size
            Me.FilePath.TabIndex = 9
            Me.LoadFromFile.FlatStyle = FlatStyle.Popup
            Me.LoadFromFile.Font = New Font("Microsoft Sans Serif", 6.75!, FontStyle.Regular, GraphicsUnit.Point, 0)
            point = New Point(&H1CB, &HCF)
            Me.LoadFromFile.Location = point
            Me.LoadFromFile.Name = "LoadFromFile"
            size = New Size(40, 20)
            Me.LoadFromFile.Size = size
            Me.LoadFromFile.TabIndex = 10
            Me.LoadFromFile.Text = "LOAD"
            Me.LoadFromFile.UseCompatibleTextRendering = True
            Me.LoadFromFile.UseVisualStyleBackColor = True
            Me.CheckBox1.AutoSize = True
            point = New Point(&HF2, &HD3)
            Me.CheckBox1.Location = point
            Me.CheckBox1.Name = "CheckBox1"
            size = New Size(15, 14)
            Me.CheckBox1.Size = size
            Me.CheckBox1.TabIndex = 11
            Me.CheckBox1.UseVisualStyleBackColor = True
            Dim ef As New SizeF(6!, 13!)
            Me.AutoScaleDimensions = ef
            Me.AutoScaleMode = AutoScaleMode.Font
            size = New Size(&H167, &HE4)
            Me.ClientSize = size
            Me.Controls.Add(Me.CheckBox1)
            Me.Controls.Add(Me.LoadFromFile)
            Me.Controls.Add(Me.FilePath)
            Me.Controls.Add(Me.RefreshList)
            Me.Controls.Add(Me.FileList)
            Me.Controls.Add(Me.OpenLoader)
            Me.Controls.Add(Me.Clear)
            Me.Controls.Add(Me.Execute)
            Me.Controls.Add(Me.ScriptCode)
            Me.FormBorderStyle = FormBorderStyle.FixedToolWindow
            Me.Icon = DirectCast(manager.GetObject("$this.Icon"), Icon)
            Me.Name = "Form_ExecuteStatement"
            Me.StartPosition = FormStartPosition.Manual
            Me.Text = "Execute Script Statement"
            Me.ResumeLayout(False)
            Me.PerformLayout
        End Sub

        Private Sub LoadFromFile_Click(ByVal sender As Object, ByVal e As EventArgs)
            Me.OpenFile.Filter = "Text (*.txt)|*.txt|JScript (*.js)|*.js"
            If (Me.OpenFile.ShowDialog = DialogResult.OK) Then
                Me.FilePath.Text = Me.OpenFile.FileName
                Me.ScriptCode.Text = Globals.LoadFile(Me.OpenFile.FileName)
            End If
        End Sub

        Private Sub OpenLoader_Click(ByVal sender As Object, ByVal e As EventArgs)
            If Me.IsLoaderOpen Then
                Me.Width = (Me.Width - 140)
                Me.OpenLoader.Text = "OPEN  >"
                Me.IsLoaderOpen = False
            Else
                Me.Width = (Me.Width + 140)
                Me.OpenLoader.Text = "CLOSE<"
                Me.IsLoaderOpen = True
                Me.RefreshList_Click(Nothing, Nothing)
            End If
        End Sub

        Private Sub RefreshList_Click(ByVal sender As Object, ByVal e As EventArgs)
            Me.CanLoad = False
            Me.Files = Directory.GetFiles((Me.FormParent.MyVars.currentDirectory & "Scripts"))
            Me.Scripts = New ArrayList
            Dim str As String
            For Each str In Me.Files
                str = Strings.Mid(str, (str.LastIndexOf("\") + 2))
                If ((Strings.InStr(str, ".txt", CompareMethod.Binary) <> 0) Or (Strings.InStr(str, ".js", CompareMethod.Binary) <> 0)) Then
                    Me.Scripts.Add(str)
                End If
            Next
            Me.FileList.DataSource = Me.Scripts
        End Sub


        ' Properties
        Friend Overridable Property CheckBox1 As CheckBox
            <DebuggerNonUserCode> _
            Get
                Return Me._CheckBox1
            End Get
            <MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode> _
            Set(ByVal WithEventsValue As CheckBox)
                Me._CheckBox1 = WithEventsValue
            End Set
        End Property

        Friend Overridable Property Clear As Button
            <DebuggerNonUserCode> _
            Get
                Return Me._Clear
            End Get
            <MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode> _
            Set(ByVal WithEventsValue As Button)
                Dim handler As EventHandler = New EventHandler(AddressOf Me.Clear_Click)
                If (Not Me._Clear Is Nothing) Then
                    RemoveHandler Me._Clear.Click, handler
                End If
                Me._Clear = WithEventsValue
                If (Not Me._Clear Is Nothing) Then
                    AddHandler Me._Clear.Click, handler
                End If
            End Set
        End Property

        Friend Overridable Property Execute As Button
            <DebuggerNonUserCode> _
            Get
                Return Me._Execute
            End Get
            <MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode> _
            Set(ByVal WithEventsValue As Button)
                Dim handler As EventHandler = New EventHandler(AddressOf Me.Execute_Click)
                If (Not Me._Execute Is Nothing) Then
                    RemoveHandler Me._Execute.Click, handler
                End If
                Me._Execute = WithEventsValue
                If (Not Me._Execute Is Nothing) Then
                    AddHandler Me._Execute.Click, handler
                End If
            End Set
        End Property

        Friend Overridable Property FileList As ComboBox
            <DebuggerNonUserCode> _
            Get
                Return Me._FileList
            End Get
            <MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode> _
            Set(ByVal WithEventsValue As ComboBox)
                Dim handler As EventHandler = New EventHandler(AddressOf Me.FileList_SelectedValueChanged)
                If (Not Me._FileList Is Nothing) Then
                    RemoveHandler Me._FileList.SelectedValueChanged, handler
                End If
                Me._FileList = WithEventsValue
                If (Not Me._FileList Is Nothing) Then
                    AddHandler Me._FileList.SelectedValueChanged, handler
                End If
            End Set
        End Property

        Friend Overridable Property FilePath As TextBox
            <DebuggerNonUserCode> _
            Get
                Return Me._FilePath
            End Get
            <MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode> _
            Set(ByVal WithEventsValue As TextBox)
                Me._FilePath = WithEventsValue
            End Set
        End Property

        Friend Overridable Property LoadFromFile As Button
            <DebuggerNonUserCode> _
            Get
                Return Me._LoadFromFile
            End Get
            <MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode> _
            Set(ByVal WithEventsValue As Button)
                Dim handler As EventHandler = New EventHandler(AddressOf Me.LoadFromFile_Click)
                If (Not Me._LoadFromFile Is Nothing) Then
                    RemoveHandler Me._LoadFromFile.Click, handler
                End If
                Me._LoadFromFile = WithEventsValue
                If (Not Me._LoadFromFile Is Nothing) Then
                    AddHandler Me._LoadFromFile.Click, handler
                End If
            End Set
        End Property

        Friend Overridable Property OpenLoader As Button
            <DebuggerNonUserCode> _
            Get
                Return Me._OpenLoader
            End Get
            <MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode> _
            Set(ByVal WithEventsValue As Button)
                Dim handler As EventHandler = New EventHandler(AddressOf Me.OpenLoader_Click)
                If (Not Me._OpenLoader Is Nothing) Then
                    RemoveHandler Me._OpenLoader.Click, handler
                End If
                Me._OpenLoader = WithEventsValue
                If (Not Me._OpenLoader Is Nothing) Then
                    AddHandler Me._OpenLoader.Click, handler
                End If
            End Set
        End Property

        Friend Overridable Property RefreshList As Button
            <DebuggerNonUserCode> _
            Get
                Return Me._RefreshList
            End Get
            <MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode> _
            Set(ByVal WithEventsValue As Button)
                Dim handler As EventHandler = New EventHandler(AddressOf Me.RefreshList_Click)
                If (Not Me._RefreshList Is Nothing) Then
                    RemoveHandler Me._RefreshList.Click, handler
                End If
                Me._RefreshList = WithEventsValue
                If (Not Me._RefreshList Is Nothing) Then
                    AddHandler Me._RefreshList.Click, handler
                End If
            End Set
        End Property

        Friend Overridable Property ScriptCode As TextBox
            <DebuggerNonUserCode> _
            Get
                Return Me._ScriptCode
            End Get
            <MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode> _
            Set(ByVal WithEventsValue As TextBox)
                Me._ScriptCode = WithEventsValue
            End Set
        End Property


        ' Fields
        <AccessedThroughProperty("CheckBox1")> _
        Private _CheckBox1 As CheckBox
        <AccessedThroughProperty("Clear")> _
        Private _Clear As Button
        <AccessedThroughProperty("Execute")> _
        Private _Execute As Button
        <AccessedThroughProperty("FileList")> _
        Private _FileList As ComboBox
        <AccessedThroughProperty("FilePath")> _
        Private _FilePath As TextBox
        <AccessedThroughProperty("LoadFromFile")> _
        Private _LoadFromFile As Button
        <AccessedThroughProperty("OpenLoader")> _
        Private _OpenLoader As Button
        <AccessedThroughProperty("RefreshList")> _
        Private _RefreshList As Button
        <AccessedThroughProperty("ScriptCode")> _
        Private _ScriptCode As TextBox
        Private CanLoad As Boolean = False
        Private components As IContainer
        Private Files As String()
        Public FormParent As Form1
        Public IsLoaderOpen As Boolean = False
        Private OpenFile As OpenFileDialog = New OpenFileDialog
        Private Scripts As ArrayList = New ArrayList
    End Class
End Namespace

